#define _CRT_SECURE_NO_WARNINGS 1
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
int hight(struct TreeNode* root) {
    if (root == NULL) {
        return 0;
    }
    int leftdep = hight(root->left);
    int rightdep = hight(root->right);
    if (leftdep > rightdep) {
        return leftdep + 1;
    }
    else {
        return rightdep + 1;
    }
}
bool isBalanced(struct TreeNode* root) {
    if (root == NULL) {
        return true;
    }
    int h1 = hight(root->left);
    int h2 = hight(root->right);
    return abs(h1 - h2) <= 1 && isBalanced(root->left) &&
        isBalanced(root->right);
}//